package com.sharp.core.voxel;

import com.sharp.core.math.AABB;
import com.sharp.core.math.Matrix;
import com.sharp.core.math.Vec3;
import com.sharp.core.math.primitives.Object3D;
import com.sharp.core.raytrace.Ray;

public class VoxelObject extends Object3D {

	private VoxelData data;
	private AABB aabb;
	
	public VoxelObject() {
	}	
	
	public VoxelObject(VoxelData data) {
		this.data = data;
		aabb = new AABB(data.getWidth(), data.getHeight(), data.getDepth());
	}

	@Override
	public void transform(Matrix m) {
		
	}
	
	

	@Override
	public void setPos(Vec3 pos) {
		super.setPos(pos);
		aabb.moveTo(pos);
	}

	@Override
	public void setPos(float x, float y, float z) {
		super.setPos(x, y, z);
		aabb.moveTo(getPos());
	}

	public VoxelData getData() {
		return data;
	}

	public void setData(VoxelData data) {
		this.data = data;
		aabb = new AABB(data.getWidth(), data.getHeight(), data.getDepth());
	}
	
	public Voxel findIntersection(Ray ray) {
		// átalakítani a koordinátákat
		return data.findIntersection(this, ray);
	}
	
	public AABB getAABB() {
		return aabb;
	}
}
